/*
 * Copyright 2009 XueSong Guo.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cn.webwheel.di;

/**
 * WebWheel DI工具的核心接口：DI容器接口。
 */
public interface Container {

    /**
     * 绑定一个类型到一个提供者。
     * @param key 类型标志
     * @param provider 实例提供者
     */
    public <T> void bind(Key<T> key, Provider<? extends T> provider);

    /**
     *获得一个类型的实例对象。
     * @param key 类型标志
     * @param data 动态参数
     * @return 实例对象
     * @throws DIException 注入异常
     */
    public <T> T getInstance(Key<T> key, String data) throws DIException;

    /**
     * 获得一个类型的提供者。
     * @param key 类型标识
     * @return 实例提供者
     */
    public <T> Provider<? extends T> getProvider(Key<T> key);

    /**
     * 创建一个类型的实例获取器
     * @param key 类型标识
     * @param data 动态参数
     * @return 实例获取器
     */
    public <T> Fetcher<T> createFetcher(Key<T> key, String data);
}
